<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Forum/classes/PhpFox_ComponentNewTopics.class.php, $Author:  $ */



/** New Forums components.
 *
 * 1. oUser (optional) - current user; for visitor - null or omitted
 *
 * @package module.forum
 * @version $Id: PhpFox_ComponentNewTopics.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 *
 */
class PhpFox_Mod_Forum_ComponentNewTopics extends BaseComponent
{

    /** Processing method
     */
	function process()
	{

	    $oReq = &App::getRequest();
	    /* @var $oReq Request */

        $oSrvSec = &App::getModuleService('Account', 'Security');
        /* @var $oSrvSec PhpFox_Mod_Account_ServiceSecurity */

		// $aTopics = App::plugin_getForumThreads();

        if (!$oSrvSec->checkAccess('forum', '', false) && !is_array($aTopics))
        {
            return '';
        }

	    //get current user
	    $oUser = $this->getParam('oUser', null);
    	$sUser = $oUser ? $oUser->aData['user'] : '';

    	$iPageSize = App::getParam('Mod_Forum.qty_new_topics');

    	if ( App::pluginInstalled('vbulletin') )
    	{
    		$iTotal = "";
    		$aTopics = vbulletin_forum_threads();
    	}
    	else
    	{
    		$aTopics = $this->oDatabase->getRows("SELECT id,user,title,time FROM `". App::getT('forum_topic') ."` ORDER BY `time` DESC LIMIT 0,". $iPageSize ."");
    	}

		$oTpl = &$this->_oModule->getTemplate();
		$oTpl->assignSrc(array(
            'aTopics'     => $aTopics,
		    'sUserPicUrl' => App::getParam('user.pic.url'),
		));
		$srcHtml = $oTpl->fetch('NewTopics.html');
		return $srcHtml;
	}

}
?>